package com.wss.day10.stream;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.DoubleSummaryStatistics;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/5/7
 */
public class Test3 {
    public static void main(String[] args) {
        List<String> list1= Stream.of("a","b","c").map(s -> s.toUpperCase()).collect(Collectors.toList());
        System.out.println(list1);
        List<Integer> list2= Stream.of(1,2,3).map(s -> s+=3).collect(Collectors.toList());
        System.out.println(list2);
        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee("张三", 7000));
        employees.add(new Employee("李四", 9000));
        employees.add(new Employee("王五", 8500));
        long employeeCount = employees.stream()
                .collect(Collectors.counting());
        System.out.println("员工人数: " + employeeCount);

        double averageSalary = employees.stream()
                .collect(Collectors.averagingDouble(Employee::getSalary));
        System.out.println("平均工资: " + averageSalary);

        double sumSalary = employees.stream()
                .collect(Collectors.summarizingDouble(Employee::getSalary)).getSum();
        System.out.println("工资总额: " + sumSalary);

        /*Employee highestPaidEmployee = employees.stream()
                .collect(Collectors.maxBy(Employee::getSalary)).map(Employee::getSalary)*/

        String joinedNames = employees.stream()
                .map(Employee::getName)
                .collect(Collectors.joining(","));
        System.out.println("所有员工名称用逗号拼接: " + joinedNames);

    }
}
